public class wait {
    //线程的等待和唤醒
    public static void main(String[] args) {
        Object object = new Object();
        Thread t1 = new Thread(()-> {
            synchronized (object){
                try {
                    object.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1线程结束");
            }
        });
        Thread t2 = new Thread(()-> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (object){
                object.notify();
                System.out.println("t2线程结束");
            }
        });
        t1.start();
        t2.start();
    }
}
